package icu.qx.diagram.service.impl;

import com.ruoyi.common.security.utils.SecurityUtils;
import icu.qx.diagram.domain.WorkReport;
import icu.qx.diagram.mapper.WorkReportMapper;
import icu.qx.diagram.service.IWorkReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkReportServiceImpl implements IWorkReportService {
    @Autowired
    private WorkReportMapper workReportMapper;
    /**
     * 报工统计
     * @param workReport
     * @return
     */
    @Override
    public List<WorkReport> selectWorkReportList(WorkReport workReport) {
        List<WorkReport> reportList=workReportMapper.selectWorkReportList(workReport);
        for(WorkReport r:reportList){
            if(r.getRecQuaPeoName()==null){
                System.out.println(r.getReportPeoCode());
                r.setRecQuaPeoName(workReportMapper.selectUserName(r));
            }
            if(r.getReportGood()==null||r.getReportCompleteNum()==null){
                r.setReportBad(0);
            }else{
                r.setReportBad(r.getReportCompleteNum()-r.getReportGood());
            }
        }
        return reportList;
    }

    @Override
    public String selectUserName(WorkReport workReport) {
        return workReportMapper.selectUserName(workReport);
    }
}
